/**
 * Copyright (C) Olafur Gauti Gudmundsson
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.solrom;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import org.solrom.annotations.IndexField;
import org.solrom.annotations.IndexFieldGetter;
import org.solrom.annotations.IndexFieldSetter;
import org.solrom.annotations.IndexSerializedField;

/**
 *
 * @author Olafur Gauti Gudmundsson
 */
public class MappedObject {
    
    public enum Suit { HEART, SPADE, DIAMOND, CLOVER }

	private String id;
	private String title;
	private double price;
	private float weight;
	private boolean inStock;
    
    @IndexField private Suit suit;
    @IndexField private Date myDateField;
	@IndexField private int stockCount;
    
    @IndexSerializedField private Set<String> stuff;
	
	public MappedObject() {
        stuff = new HashSet<String>();
	}

	@IndexFieldGetter
	public float getWeight() {
		return weight;
	}

	@IndexFieldSetter
	public void setWeight(float weight) {
		this.weight = weight;
	}

	@IndexFieldGetter(id = true)
	public String getId() {
		return id;
	}

	@IndexFieldSetter
	public void setId(String id) {
		this.id = id;
	}

	@IndexFieldGetter
	public boolean isInStock() {
		return inStock;
	}

	@IndexFieldSetter
	public void setInStock(boolean inStock) {
		this.inStock = inStock;
	}

	@IndexFieldGetter
	public double getPrice() {
		return price;
	}

	@IndexFieldSetter
	public void setPrice(double price) {
		this.price = price;
	}

	@IndexFieldGetter
	public String getTitle() {
		return title;
	}

	@IndexFieldSetter
	public void setTitle(String title) {
		this.title = title;
	}
	
	@IndexFieldGetter(name = "myDerivedValue")
	public String getDerivedValue() {
		return title.toLowerCase() + "_" + price;
	}
	
	@IndexFieldSetter(name = "myDerivedValue")
	public void setDerivedValue( String value ) {
		System.out.println("Got derived value: " + value);
	}

	public int getStockCount() {
		return stockCount;
	}

	public void setStockCount(int stockCount) {
		this.stockCount = stockCount;
	}

    public Date getMyDateField() {
        return myDateField;
    }

    public void setMyDateField(Date myDateField) {
        this.myDateField = myDateField;
    }

    public Suit getSuit() {
        return suit;
    }

    public void setSuit(Suit suit) {
        this.suit = suit;
    }

    public Set<String> getStuff() {
        return stuff;
    }

    public void setStuff(Set<String> stuff) {
        this.stuff = stuff;
    }

}
